# HG changeset patch
# User Christophe Capon <christophe.capon@vilogia.fr>
# Date 1269455757 -3600
# Branch 5.3.0
# Node ID 296d11e89e18240556578fe2a5bc5a8fa58624f2
# Parent  85f02435e44d2226dfda8c5b556479bc509c3210
Removed the impersonate-web, nothing to do in the nuxeo trunk

diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/pom.xml
--- a/nuxeo-platform-impersonate-web/pom.xml	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.nuxeo.ecm.platform</groupId>
-    <artifactId>nuxeo-services-parent</artifactId>
-    <version>5.3.0</version>
-  </parent>
-
-  <artifactId>nuxeo-platform-impersonate-web</artifactId>
-  <name>Nuxeo Anonymous Blog</name>
-  <description>Nuxeo Enterprise Platform: Anonymous blog</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.jboss.seam</groupId>
-      <artifactId>jboss-seam</artifactId>
-    </dependency>
-
-      <dependency>
-        <groupId>org.restlet</groupId>
-        <artifactId>org.restlet</artifactId>
-        <version>1.0.7</version>
-      </dependency>
-      <dependency>
-        <groupId>org.restlet</groupId>
-        <artifactId>org.restlet.ext.fileupload</artifactId>
-        <version>1.0.7</version>
-      </dependency>
-      <dependency>
-        <groupId>com.noelios.restlet</groupId>
-        <artifactId>com.noelios.restlet</artifactId>
-        <version>1.0.7</version>
-      </dependency>
-      <dependency>
-        <groupId>com.noelios.restlet</groupId>
-        <artifactId>com.noelios.restlet.ext.servlet</artifactId>
-        <version>1.0.7</version>
-      </dependency>
-
-    <dependency>
-      <groupId>org.nuxeo.ecm.platform</groupId>
-      <artifactId>nuxeo-platform-ui-web</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.nuxeo.ecm.core</groupId>
-      <artifactId>nuxeo-core-api</artifactId>
-    </dependency>
-  </dependencies>
-
-</project>
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/AllowedAnonymousBlogs.java
--- a/nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/AllowedAnonymousBlogs.java	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-package org.nuxeo.ecm.platform.ui.web.auth.plugins.passthrough;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.nuxeo.common.xmap.annotation.XNodeList;
-import org.nuxeo.common.xmap.annotation.XObject;
-
-@XObject("anonymousBlogs")
-public class AllowedAnonymousBlogs {
-
-    @XNodeList(value="allowedBlog", type=ArrayList.class, componentType=AllowedBlogDescriptor.class)
-    public List<AllowedBlogDescriptor> allowedBlogs;
-
-}
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/AllowedBlogDescriptor.java
--- a/nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/AllowedBlogDescriptor.java	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package org.nuxeo.ecm.platform.ui.web.auth.plugins.passthrough;
-
-import org.nuxeo.common.xmap.annotation.XNode;
-import org.nuxeo.common.xmap.annotation.XObject;
-
-@XObject("blogDescriptor")
-public class AllowedBlogDescriptor {
-
-    @XNode("name")
-    public String name;
-    
-    @XNode("user")
-    public String user;
-    
-    @XNode("password")
-    public String password;
-
-}
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/BlogAuthenticator.java
--- a/nuxeo-platform-impersonate-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/plugins/passthrough/BlogAuthenticator.java	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public License
- * (LGPL) version 2.1 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Contributors:
- *     Thierry Delprat
- *
- * $Id: AnonymousAuthenticator.java 30865 2008-03-11 09:00:53Z arussel $
- */
-
-package org.nuxeo.ecm.platform.ui.web.auth.plugins.passthrough;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuxeo.common.xmap.XMap;
-import org.nuxeo.ecm.platform.api.login.UserIdentificationInfo;
-import org.nuxeo.ecm.platform.ui.web.auth.interfaces.NuxeoAuthenticationPlugin;
-import org.nuxeo.ecm.platform.ui.web.auth.interfaces.NuxeoAuthenticationPluginLogoutExtension;
-
-/**
- * 
- * @author Thierry Delprat
- */
-public class BlogAuthenticator implements NuxeoAuthenticationPlugin, NuxeoAuthenticationPluginLogoutExtension {
-
-    private static Log log = LogFactory.getLog(BlogAuthenticator.class);
-    
-    private static final String BLOG_MARKER = "/site/blogs/";
-    private static XMap xmap = null;
-
-    private void initXmap() {
-
-	if (xmap == null) {
-	    log.info("Initialize XMap for configuration file");
-	    xmap = new XMap();
-	    xmap.register(AllowedAnonymousBlogs.class);
-	}
-    }
-
-    public UserIdentificationInfo handleRetrieveIdentity(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
-
-	try {
-
-	    AllowedBlogDescriptor desc = getBlogDescriptor(httpRequest);
-
-	    if (desc != null) {
-		return new UserIdentificationInfo(desc.user, desc.password);
-	    }
-
-	} catch (Exception e) {
-	    log.info(String.format("Error while trying to connect to %s", httpRequest.getRequestURI()), e);
-	}
-	return null;
-
-    }
-
-    private AllowedBlogDescriptor getBlogDescriptor(HttpServletRequest httpRequest) {
-
-	String url = httpRequest.getRequestURL().toString();
-
-	if (url.contains(BlogAuthenticator.BLOG_MARKER)) {
-	    String blogName = url.substring(url.indexOf(BLOG_MARKER) + BLOG_MARKER.length());
-	    return getBlogDescriptor(blogName);
-	}
-
-	return null;
-
-    }
-
-    private AllowedBlogDescriptor getBlogDescriptor(String blog) {
-
-	List<AllowedBlogDescriptor> allowedBlogs = getAllowedBlogs();
-
-	for (AllowedBlogDescriptor desc : allowedBlogs) {
-	    if (desc.name.equals(blog))
-		return desc;
-	}
-	return null;
-
-    }
-
-    private List<AllowedBlogDescriptor> getAllowedBlogs() {
-	initXmap();
-	AllowedAnonymousBlogs allowedBlogs = loadAllowedBlogFile();
-	return allowedBlogs.allowedBlogs;
-    }
-
-    private AllowedAnonymousBlogs loadAllowedBlogFile() {
-
-	AllowedAnonymousBlogs result = new AllowedAnonymousBlogs();
-	result.allowedBlogs = new ArrayList<AllowedBlogDescriptor>();
-
-	try {
-	    URL url = getClass().getResource("/config/allowedblogs.xml");
-	    Object[] config = (Object[]) xmap.loadAll(url);
-	    if (config.length > 0)
-		result = (AllowedAnonymousBlogs) config[0];
-	} catch (MalformedURLException e) {
-	} catch (Exception e) {
-	    e.printStackTrace();
-	}
-
-	return result;
-    }
-
-    public void initPlugin(Map<String, String> parameters) {
-	// NOP
-    }
-
-    public Boolean needLoginPrompt(HttpServletRequest httpRequest) {
-	return Boolean.FALSE;
-    }
-
-    public List<String> getUnAuthenticatedURLPrefix() {
-	return null;
-    }
-
-    public Boolean handleLoginPrompt(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String baseURL) {
-	return null;
-    }
-
-    public Boolean handleLogout(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
-	return Boolean.FALSE;
-    }
-
-}
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/resources/META-INF/MANIFEST.MF
--- a/nuxeo-platform-impersonate-web/src/main/resources/META-INF/MANIFEST.MF	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 1
-Bundle-Name: Vilogia training bundle
-Bundle-SymbolicName: org.nuxeo.ecm.impersonate.web;singleton=true
-Bundle-Vendor: Nuxeo
-Bundle-Category: stateless
-Require-Bundle: org.nuxeo.ecm.core.api
-Nuxeo-Component: OSGI-INF/blog-authentication-contrib.xml
- 
\ No newline at end of file
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/resources/OSGI-INF/blog-authentication-contrib.xml
--- a/nuxeo-platform-impersonate-web/src/main/resources/OSGI-INF/blog-authentication-contrib.xml	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-<component name="org.nuxeo.ecm.platform.ui.web.auth.blogPassthroughConfig">
-
-	<require>org.nuxeo.ecm.platform.ui.web.auth.defaultConfig</require>
-	<require>org.nuxeo.opensocial.OAuthFilter</require>
-	<require>org.nuxeo.ecm.platform.ui.web.auth.WebEngineConfig</require>
-
-	<extension target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService" point="authenticators">
-
-		<authenticationPlugin name="ANONYMOUS_BLOG_AUTH" enabled="true"
-			class="org.nuxeo.ecm.platform.ui.web.auth.plugins.passthrough.BlogAuthenticator">
-			<parameters>
-				<parameter name="URLSkip">webservices/</parameter>
-			</parameters>
-		</authenticationPlugin>
-	</extension>
-
-	<extension target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService" point="chain">
-
-		<authenticationChain>
-			<plugins>
-				<plugin>ANONYMOUS_BLOG_AUTH</plugin>
-				<plugin>BASIC_AUTH</plugin>
-				<plugin>FORM_AUTH</plugin>
-				<plugin>WEBENGINE_FORM_AUTH</plugin>
-				<plugin>ANONYMOUS_AUTH</plugin>
-				<plugin>WEBSERVICES_AUTH</plugin>
-			</plugins>
-		</authenticationChain>
-
-	</extension>
-
-</component>
diff -r 85f02435e44d -r 296d11e89e18 nuxeo-platform-impersonate-web/src/main/resources/OSGI-INF/deployment-fragment.xml
--- a/nuxeo-platform-impersonate-web/src/main/resources/OSGI-INF/deployment-fragment.xml	Tue Mar 23 06:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-
-<fragment>
-
-	<extension target="application#MODULE">
-		<module>
-			<java>${bundle.fileName}</java>
-		</module>
-	</extension>
-
-</fragment>
diff -r 85f02435e44d -r 296d11e89e18 pom.xml
--- a/pom.xml	Tue Mar 23 06:32:02 2010 +0100
+++ b/pom.xml	Wed Mar 24 19:35:57 2010 +0100
@@ -42,7 +42,6 @@
     <module>nuxeo-platform-alert-lock-core</module>
     <module>nuxeo-platform-alert-task-core</module>
     <module>nuxeo-platform-alert-deferred-core</module>
-    <module>nuxeo-platform-impersonate-web</module>
     <module>nuxeo-platform-notification-core</module>
   </modules>
 
# HG changeset patch
# User Christophe Capon <christophe.capon@vilogia.fr>
# Date 1269587119 -3600
# Branch 5.3.0
# Node ID b5ae2801e4a055eca1fd4bab420b0cf7e1c32956
# Parent  cca23b73e7257ad9a75d2c3a399e62d0b458945f
Removed all e.printStackTrace, used logger instead

diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertManagementService.java
--- a/nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertManagementService.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertManagementService.java	Fri Mar 26 08:05:19 2010 +0100
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.nuxeo.ecm.core.api.ClientException;
+
 /**
  * Alert management service
  * 
@@ -33,9 +35,10 @@
 
     /**
      * Process the alerts raised by the registered providers.
+     * @throws ClientException 
      */
 
-    public void processAlerts(AlertContext ctx);
+    public void processAlerts(AlertContext ctx) throws ClientException;
 
     /**
      * Registers an alert provider
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertProvider.java
--- a/nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertProvider.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-api/src/main/java/org/nuxeo/ecm/alert/AlertProvider.java	Fri Mar 26 08:05:19 2010 +0100
@@ -25,9 +25,10 @@
      * provider
      * 
      * @param rs rendering service to initialize
+     * @throws ClientException 
      */
     
-    public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession);
+    public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession) throws ClientException;
     
     
     /**
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java
--- a/nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java	Fri Mar 26 08:05:19 2010 +0100
@@ -113,7 +113,7 @@
         log.trace("Instanciating AlertManagementServiceImpl");
     }
 
-    public void processAlerts(AlertContext ctx) {
+    public void processAlerts(AlertContext ctx) throws ClientException {
 
         try {
 
@@ -131,8 +131,8 @@
             close(coreSession, ctx);
 
         } catch (Exception e) {
-
-            e.printStackTrace();
+            
+            throw new ClientException("processAlerts failed", e);
 
         }
 
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-deferred-core/src/main/java/org/nuxeo/ecm/alert/deferred/core/DeferredAlertProvider.java
--- a/nuxeo-platform-alert-deferred-core/src/main/java/org/nuxeo/ecm/alert/deferred/core/DeferredAlertProvider.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-deferred-core/src/main/java/org/nuxeo/ecm/alert/deferred/core/DeferredAlertProvider.java	Fri Mar 26 08:05:19 2010 +0100
@@ -1,6 +1,5 @@
 package org.nuxeo.ecm.alert.deferred.core;
 
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -31,189 +30,189 @@
 import org.nuxeo.runtime.api.Framework;
 
 import com.nuxeo.ecm.deferredalert.types.DeferredAlertWrapper;
-import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
 
 public class DeferredAlertProvider implements AlertProvider {
 
-	private DocumentViewCodecManager docLocator = null;
+    private DocumentViewCodecManager docLocator = null;
 
-	private static final Log log = LogFactory.getLog(DeferredAlertProvider.class);
+    private static final Log log = LogFactory.getLog(DeferredAlertProvider.class);
 
-	public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession) {
+    public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession)
+            throws ClientException {
 
-		Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
+        Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
 
-		try {
+        String query = "select * from DeferredAlert";
 
-			String query = "select * from DeferredAlert";
+        DocumentModelList docs = coreSession.query(query);
 
-			DocumentModelList docs = coreSession.query(query);
+        populateAlerts(coreSession, result, docs);
 
-			populateAlerts(coreSession, result, docs);
+        return result;
 
-		} catch (ClientException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+    }
 
-		return result;
+    private void populateAlerts(CoreSession coreSession,
+            Map<String, UserAlerts> result, DocumentModelList docs)
+            throws ClientException {
 
-	}
+        Iterator<DocumentModel> docIter = docs.iterator();
 
-	private void populateAlerts(CoreSession coreSession, Map<String, UserAlerts> result, DocumentModelList docs)
-			throws ClientException, ParseException {
+        while (docIter.hasNext()) {
 
-		Iterator<DocumentModel> docIter = docs.iterator();
+            DocumentModel currentDoc = docIter.next();
+            DeferredAlertWrapper w = new DeferredAlertWrapper(currentDoc);
 
-		while (docIter.hasNext()) {
+            AlertInfo info = new AlertInfo();
+            info.setDocRef(currentDoc.getRef());
+            info.setUserName(w.getUserName());
+            info.setAlertText(w.getAlertText());
+            info.setAlertDate(w.getCreationDateAsString());
+            addCurrentAlert(result, currentDoc, info);
 
-			DocumentModel currentDoc = docIter.next();
-			DeferredAlertWrapper w = new DeferredAlertWrapper(currentDoc);
+        }
 
-			AlertInfo info = new AlertInfo();
-			info.setDocRef(currentDoc.getRef());
-			info.setUserName(w.getUserName());
-			info.setAlertText(w.getAlertText());
-			info.setAlertDate(w.getCreationDateAsString());
-			addCurrentAlert(result, currentDoc, info);
+    }
 
-		}
+    private void addCurrentAlert(Map<String, UserAlerts> result,
+            DocumentModel currentDoc, AlertInfo alertDesc) {
 
-	}
+        UserAlerts alerts = getCurrentUserAlerts(result,
+                alertDesc.getUserName());
 
-	private void addCurrentAlert(Map<String, UserAlerts> result, DocumentModel currentDoc, AlertInfo alertDesc) {
+        alerts.getAlerts().add(
+                new Alert("DeferredAlertProvider", "deferred", alertDesc));
 
-		UserAlerts alerts = getCurrentUserAlerts(result, alertDesc.getUserName());
+    }
 
-		alerts.getAlerts().add(new Alert("DeferredAlertProvider", "deferred", alertDesc));
+    private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result,
+            String userName) {
 
-	}
+        if (!result.containsKey(userName)) {
 
-	private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result, String userName) {
+            UserAlerts alerts = new UserAlerts(userName);
 
-		if (!result.containsKey(userName)) {
+            result.put(userName, alerts);
 
-			UserAlerts alerts = new UserAlerts(userName);
+        }
 
-			result.put(userName, alerts);
+        UserAlerts alerts = result.get(userName);
 
-		}
+        return alerts;
+    }
 
-		UserAlerts alerts = result.get(userName);
+    public String renderAlerts(CoreSession coreSession, RenderingService rs,
+            String userName, List<Alert> alerts, DocumentModel userSettingsDoc,
+            AlertContext ctxt) {
 
-		return alerts;
-	}
+        String result = "";
 
-	public String renderAlerts(CoreSession coreSession, RenderingService rs, String userName, List<Alert> alerts,
-			DocumentModel userSettingsDoc, AlertContext ctxt) {
+        try {
 
-		String result = "";
+            AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
 
-		try {
+            List<AlertInfo> alertList = new ArrayList<AlertInfo>();
 
-			AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
+            for (Alert a : alerts) {
 
-			List<AlertInfo> alertList = new ArrayList<AlertInfo>();
+                if (a.getAlertProviderName() == "DeferredAlertProvider") {
 
-			for (Alert a : alerts) {
+                    AlertInfo ai = (AlertInfo) a.getAlertData();
 
-				if (a.getAlertProviderName() == "DeferredAlertProvider") {
+                    alertList.add(ai);
 
-					AlertInfo ai = (AlertInfo) a.getAlertData();
+                }
 
-					alertList.add(ai);
+            }
 
-				}
+            DeferredRenderingContext ctx = new DeferredRenderingContext();
+            ctx.put("template", "deferredAlert");
+            ctx.put("alerts", alertList);
+            ctx.put("format", w.getAlertDeliveryChannel());
 
-			}
+            Collection<RenderingResult> render = rs.process(ctx);
+            if (render.size() > 0) {
+                result = (String) render.iterator().next().getOutcome();
+            }
 
-			DeferredRenderingContext ctx = new DeferredRenderingContext();
-			ctx.put("template", "deferredAlert");
-			ctx.put("alerts", alertList);
-			ctx.put("format", w.getAlertDeliveryChannel());
+            if (!ctxt.isNoPurge()) {
 
-			Collection<RenderingResult> render = rs.process(ctx);
-			if (render.size() > 0) {
-				result = (String) render.iterator().next().getOutcome();
-			}
+                for (Alert a : alerts) {
 
-			if (!ctxt.isNoPurge()) {
-				
-				for (Alert a : alerts) {
+                    if (a.getAlertProviderName() == "DeferredAlertProvider") {
 
-					if (a.getAlertProviderName() == "DeferredAlertProvider") {
+                        AlertInfo ai = (AlertInfo) a.getAlertData();
+                        coreSession.removeDocument(ai.getDocRef());
 
-						AlertInfo ai = (AlertInfo) a.getAlertData();
-						coreSession.removeDocument(ai.getDocRef());
-						
-					}
-				}
-				
-				coreSession.save();
-				
-			}
+                    }
+                }
 
-		} catch (Exception e) {
-			log.error("Unable to render deferred alerts", e);
-		}
+                coreSession.save();
 
-		return result;
+            }
 
-	}
+        } catch (Exception e) {
+            log.error("Unable to render deferred alerts", e);
+        }
 
-	public DocumentViewCodecManager getLocator() {
+        return result;
 
-		if (docLocator == null) {
-			try {
-				docLocator = Framework.getService(DocumentViewCodecManager.class);
-			} catch (Exception e) {
+    }
 
-			}
-		}
+    public DocumentViewCodecManager getLocator() {
 
-		return docLocator;
-	}
+        if (docLocator == null) {
+            try {
+                docLocator = Framework.getService(DocumentViewCodecManager.class);
+            } catch (Exception e) {
 
-	public String getDocLocation(DocumentModel doc) {
+            }
+        }
 
-		DocumentLocation docLoc = new DocumentLocationImpl(doc);
-		DocumentView docView = new DocumentViewImpl(docLoc);
-		docView.setViewId("view_documents");
+        return docLocator;
+    }
 
-		return getLocator().getUrlFromDocumentView(docView, true,
-				NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
+    public String getDocLocation(DocumentModel doc) {
 
-	}
+        DocumentLocation docLoc = new DocumentLocationImpl(doc);
+        DocumentView docView = new DocumentViewImpl(docLoc);
+        docView.setViewId("view_documents");
 
-	public List<String> getTemplateList() {
+        return getLocator().getUrlFromDocumentView(
+                docView,
+                true,
+                NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
 
-		List<String> result = new ArrayList<String>();
-		result.add("deferredAlert");
-		return result;
+    }
 
-	}
+    public List<String> getTemplateList() {
 
-	protected DocumentModel getUserWorkspace(CoreSession session, String userName) throws ClientException {
+        List<String> result = new ArrayList<String>();
+        result.add("deferredAlert");
+        return result;
 
-		try {
+    }
 
-			UserWorkspaceService uws = Framework.getService(UserWorkspaceService.class);
+    protected DocumentModel getUserWorkspace(CoreSession session,
+            String userName) throws ClientException {
 
-			DocumentModel userWorkspace = uws.getCurrentUserPersonalWorkspace(userName, session.getRootDocument());
+        try {
 
-			session.save();
+            UserWorkspaceService uws = Framework.getService(UserWorkspaceService.class);
 
-			return userWorkspace;
+            DocumentModel userWorkspace = uws.getCurrentUserPersonalWorkspace(
+                    userName, session.getRootDocument());
 
-		} catch (ClientException e) {
-			throw e;
-		} catch (Exception e) {
-			throw new ClientException(e);
-		}
+            session.save();
 
-	}
+            return userWorkspace;
+
+        } catch (ClientException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new ClientException(e);
+        }
+
+    }
 
 }
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-lock-core/src/main/java/org/nuxeo/ecm/alert/lock/core/LockAlertProvider.java
--- a/nuxeo-platform-alert-lock-core/src/main/java/org/nuxeo/ecm/alert/lock/core/LockAlertProvider.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-lock-core/src/main/java/org/nuxeo/ecm/alert/lock/core/LockAlertProvider.java	Fri Mar 26 08:05:19 2010 +0100
@@ -4,6 +4,7 @@
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -32,166 +33,182 @@
 
 public class LockAlertProvider implements AlertProvider {
 
-	private static final Log log = LogFactory.getLog(LockAlertProvider.class);
+    private static final Log log = LogFactory.getLog(LockAlertProvider.class);
 
-	private DocumentViewCodecManager docLocator = null;
+    private DocumentViewCodecManager docLocator = null;
 
-	public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession) {
+    public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession)
+            throws ClientException {
 
-		Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
+        Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
 
-		try {
+        String query = "select * from document where ecm:lock <> ''";
 
-			String query = "select * from document where ecm:lock <> ''";
+        DocumentModelList docs = coreSession.query(query);
 
-			DocumentModelList docs = coreSession.query(query);
+        populateAlerts(coreSession, result, docs);
 
-			populateAlerts(coreSession, result, docs);
+        return result;
 
-		} catch (ClientException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+    }
 
-		return result;
+    private void populateAlerts(CoreSession coreSession,
+            Map<String, UserAlerts> result, DocumentModelList docs)
+            throws ClientException {
 
-	}
+        Iterator<DocumentModel> docIter = docs.iterator();
 
-	private void populateAlerts(CoreSession coreSession, Map<String, UserAlerts> result, DocumentModelList docs)
-			throws ClientException, ParseException {
+        while (docIter.hasNext()) {
 
-		Iterator<DocumentModel> docIter = docs.iterator();
+            DocumentModel currentDoc = docIter.next();
 
-		while (docIter.hasNext()) {
+            LockDescriptor lockDesc = getLockDescriptor(coreSession, currentDoc);
 
-			DocumentModel currentDoc = docIter.next();
+            addCurrentAlert(result, currentDoc, lockDesc);
 
-			LockDescriptor lockDesc = getLockDescriptor(coreSession, currentDoc);
+        }
 
-			addCurrentAlert(result, currentDoc, lockDesc);
+    }
 
-		}
+    private void addCurrentAlert(Map<String, UserAlerts> result,
+            DocumentModel currentDoc, LockDescriptor lockDesc) {
 
-	}
+        UserAlerts alerts = getCurrentUserAlerts(result, lockDesc.getLocker());
 
-	private void addCurrentAlert(Map<String, UserAlerts> result, DocumentModel currentDoc, LockDescriptor lockDesc) {
+        alerts.getAlerts().add(new Alert("LockAlertProvider", "lock", lockDesc));
 
-		UserAlerts alerts = getCurrentUserAlerts(result, lockDesc.getLocker());
+    }
 
-		alerts.getAlerts().add(new Alert("LockAlertProvider", "lock", lockDesc));
+    /**
+     * 
+     * The lock date is not that important, so we safely assume that the lock
+     * date is now is something unexpected happens. his might occur if the
+     * DateFormat.MEDIUM is changed in the
+     * {@link org.nuxeo.ecm.webapp.edit.lock.LockActionsBean#getDocumentLockKey()
+     * lock implementation}
+     */
 
-	}
+    private LockDescriptor getLockDescriptor(CoreSession coreSession,
+            DocumentModel currentDoc) throws ClientException {
 
-	private LockDescriptor getLockDescriptor(CoreSession coreSession, DocumentModel currentDoc) throws ClientException,
-			ParseException {
+        String lock = coreSession.getLock(currentDoc.getRef());
+        String lockDetail[] = lock.split(":");
+        String userName = lockDetail[0];
+        String lockedDate = lockDetail[1];
 
-		String lock = coreSession.getLock(currentDoc.getRef());
-		String lockDetail[] = lock.split(":");
-		String userName = lockDetail[0];
-		String lockedDate = lockDetail[1];
+        LockDescriptor result = new LockDescriptor();
 
-		LockDescriptor result = new LockDescriptor();
+        result.setLocker(userName);
+        result.setDocRef(currentDoc.getRef());
 
-		result.setLocker(userName);
-		result.setDocRef(currentDoc.getRef());
-		result.setSince(DateFormat.getDateInstance(DateFormat.MEDIUM).parse(lockedDate));
+        // See function comment, we handle graciously the parse exception
+        try {
+            result.setSince(DateFormat.getDateInstance(DateFormat.MEDIUM).parse(
+                    lockedDate));
+        } catch (ParseException e) {
+            log.warn(String.format(
+                    "Unable to parse the following date : %s, assuming today",
+                    lockedDate == null ? "<NULL>" : lockedDate));
+            result.setSince(new Date());
+        }
 
-		return result;
-	}
+        return result;
+    }
 
-	private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result, String userName) {
+    private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result,
+            String userName) {
 
-		if (!result.containsKey(userName)) {
+        if (!result.containsKey(userName)) {
 
-			UserAlerts alerts = new UserAlerts(userName);
+            UserAlerts alerts = new UserAlerts(userName);
 
-			result.put(userName, alerts);
+            result.put(userName, alerts);
 
-		}
+        }
 
-		UserAlerts alerts = result.get(userName);
-		return alerts;
-	}
+        UserAlerts alerts = result.get(userName);
+        return alerts;
+    }
 
-	public String renderAlerts(CoreSession coreSession, RenderingService rs, String userName, List<Alert> alerts,
-			DocumentModel userSettingsDoc, AlertContext ctxt) {
+    public String renderAlerts(CoreSession coreSession, RenderingService rs,
+            String userName, List<Alert> alerts, DocumentModel userSettingsDoc,
+            AlertContext ctxt) {
 
-		String result = "";
+        String result = "";
 
-		try {
-			
-			AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
-			
-			List<LockInfo> docs = new ArrayList<LockInfo>();
+        try {
 
-			for (Alert a : alerts) {
+            AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
 
-				if (a.getAlertProviderName() == "LockAlertProvider") {
+            List<LockInfo> docs = new ArrayList<LockInfo>();
 
-					LockDescriptor dr = (LockDescriptor) a.getAlertData();
+            for (Alert a : alerts) {
 
-					LockInfo li = new LockInfo();
+                if (a.getAlertProviderName() == "LockAlertProvider") {
 
-					DocumentModel currentDoc = coreSession.getDocument(dr.getDocRef());
-					li.setDocTitle(currentDoc.getTitle());
-					li.setDocUrl(getDocLocation(currentDoc));
-					li.setLockedSince(dr.getSince());
-					docs.add(li);
+                    LockDescriptor dr = (LockDescriptor) a.getAlertData();
 
-				}
+                    LockInfo li = new LockInfo();
 
-			}
+                    DocumentModel currentDoc = coreSession.getDocument(dr.getDocRef());
+                    li.setDocTitle(currentDoc.getTitle());
+                    li.setDocUrl(getDocLocation(currentDoc));
+                    li.setLockedSince(dr.getSince());
+                    docs.add(li);
 
-			LockRenderingContext ctx = new LockRenderingContext();
-			ctx.put("template", "lockAlert");
-			ctx.put("docs", docs);
-			ctx.put("format", w.getAlertDeliveryChannel());
+                }
 
-			Collection<RenderingResult> render = rs.process(ctx);
-			if (render.size() > 0) {
-				result = (String) render.iterator().next().getOutcome();
-			}
-		} catch (Exception e) {
-			log.error("Unable to render lock alerts", e);
-		}
+            }
 
-		return result;
+            LockRenderingContext ctx = new LockRenderingContext();
+            ctx.put("template", "lockAlert");
+            ctx.put("docs", docs);
+            ctx.put("format", w.getAlertDeliveryChannel());
 
-	}
+            Collection<RenderingResult> render = rs.process(ctx);
+            if (render.size() > 0) {
+                result = (String) render.iterator().next().getOutcome();
+            }
+        } catch (Exception e) {
+            log.error("Unable to render lock alerts", e);
+        }
 
-	public DocumentViewCodecManager getLocator() {
+        return result;
 
-		if (docLocator == null) {
-			try {
-				docLocator = Framework.getService(DocumentViewCodecManager.class);
-			} catch (Exception e) {
+    }
 
-			}
-		}
+    public DocumentViewCodecManager getLocator() {
 
-		return docLocator;
-	}
+        if (docLocator == null) {
+            try {
+                docLocator = Framework.getService(DocumentViewCodecManager.class);
+            } catch (Exception e) {
 
-	public String getDocLocation(DocumentModel doc) {
+            }
+        }
 
-		DocumentLocation docLoc = new DocumentLocationImpl(doc);
-		DocumentView docView = new DocumentViewImpl(docLoc);
-		docView.setViewId("view_documents");
+        return docLocator;
+    }
 
-		return getLocator().getUrlFromDocumentView(docView, true,
-				NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
+    public String getDocLocation(DocumentModel doc) {
 
-	}
+        DocumentLocation docLoc = new DocumentLocationImpl(doc);
+        DocumentView docView = new DocumentViewImpl(docLoc);
+        docView.setViewId("view_documents");
 
-	public List<String> getTemplateList() {
+        return getLocator().getUrlFromDocumentView(
+                docView,
+                true,
+                NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
 
-		List<String> result = new ArrayList<String>();
-		result.add("lockAlert");
-		return result;
+    }
 
-	}
+    public List<String> getTemplateList() {
+
+        List<String> result = new ArrayList<String>();
+        result.add("lockAlert");
+        return result;
+
+    }
 
 }
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/TaskAlertProvider.java
--- a/nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/TaskAlertProvider.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/TaskAlertProvider.java	Fri Mar 26 08:05:19 2010 +0100
@@ -30,147 +30,148 @@
 
 public class TaskAlertProvider implements AlertProvider {
 
-	private DocumentViewCodecManager docLocator = null;
+    private DocumentViewCodecManager docLocator = null;
 
-	private static final Log log = LogFactory.getLog(TaskAlertProvider.class);
+    private static final Log log = LogFactory.getLog(TaskAlertProvider.class);
 
-	public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession) {
+    public Map<String, UserAlerts> getAllPendingAlerts(CoreSession coreSession) {
 
-		Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
+        Map<String, UserAlerts> result = new HashMap<String, UserAlerts>();
 
-		WorkflowHelper helper = new WorkflowHelper();
+        WorkflowHelper helper = new WorkflowHelper();
+        List<TaskDescriptor> tasks = helper.getAllOpenTaskInstances();
 
-		try {
+        for (TaskDescriptor task : tasks)
+            getCurrentUserAlerts(result, task.getActor()).getAlerts().add(
+                    new Alert("TaskAlertProvider", "task", task));
 
-			List<TaskDescriptor> tasks = helper.getAllOpenTaskInstances();
+        return result;
 
-			for (TaskDescriptor task : tasks)
-				getCurrentUserAlerts(result, task.getActor()).getAlerts().add(new Alert("TaskAlertProvider", "task", task));
+    }
 
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+    private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result,
+            String userName) {
 
-		return result;
+        if (!result.containsKey(userName)) {
 
-	}
+            UserAlerts alerts = new UserAlerts(userName);
 
-	private UserAlerts getCurrentUserAlerts(Map<String, UserAlerts> result, String userName) {
+            result.put(userName, alerts);
 
-		if (!result.containsKey(userName)) {
+        }
 
-			UserAlerts alerts = new UserAlerts(userName);
+        UserAlerts alerts = result.get(userName);
 
-			result.put(userName, alerts);
+        return alerts;
+    }
 
-		}
+    public String renderAlerts(CoreSession coreSession, RenderingService rs,
+            String userName, List<Alert> alerts, DocumentModel userSettingsDoc,
+            AlertContext ctxt) {
 
-		UserAlerts alerts = result.get(userName);
+        String result = "";
 
-		return alerts;
-	}
+        try {
 
-	public String renderAlerts(CoreSession coreSession, RenderingService rs, String userName, List<Alert> alerts,
-			DocumentModel userSettingsDoc, AlertContext ctxt) {
+            AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
 
-		String result = "";
+            List<DocumentInfo> docs = new ArrayList<DocumentInfo>();
 
-		try {
+            for (Alert a : alerts) {
 
-			AlertSettingsWrapper w = new AlertSettingsWrapper(userSettingsDoc);
+                if (a.getAlertProviderName() == "TaskAlertProvider") {
 
-			List<DocumentInfo> docs = new ArrayList<DocumentInfo>();
+                    TaskDescriptor td = (TaskDescriptor) a.getAlertData();
 
-			for (Alert a : alerts) {
+                    if (isEligible(td, w)) {
+                        DocumentInfo di = new DocumentInfo();
+                        DocumentModel dm = coreSession.getDocument(new IdRef(
+                                td.getDocumentId()));
+                        di.setDocTitle(dm.getTitle());
+                        di.setDocUrl(getDocLocation(dm));
+                        di.setDueDate(td.getDueDate());
+                        di.setLate(td.getDueDate() != null
+                                && td.getDueDate().before(new Date()));
+                        docs.add(di);
+                    }
 
-				if (a.getAlertProviderName() == "TaskAlertProvider") {
+                }
 
-					TaskDescriptor td = (TaskDescriptor) a.getAlertData();
+            }
 
-					if (isEligible(td, w)) {
-						DocumentInfo di = new DocumentInfo();
-						DocumentModel dm = coreSession.getDocument(new IdRef(td.getDocumentId()));
-						di.setDocTitle(dm.getTitle());
-						di.setDocUrl(getDocLocation(dm));
-						di.setDueDate(td.getDueDate());
-						di.setLate(td.getDueDate() != null && td.getDueDate().before(new Date()));
-						docs.add(di);
-					}
+            TaskRenderingContext ctx = new TaskRenderingContext();
+            ctx.put("template", "taskAlert");
+            ctx.put("docs", docs);
+            ctx.put("format", w.getAlertDeliveryChannel());
 
-				}
+            Collection<RenderingResult> render = rs.process(ctx);
+            if (render.size() > 0) {
+                result = (String) render.iterator().next().getOutcome();
+            }
+        } catch (Exception e) {
+            log.error("Unable to render task alerts", e);
+        }
 
-			}
+        return result;
 
-			TaskRenderingContext ctx = new TaskRenderingContext();
-			ctx.put("template", "taskAlert");
-			ctx.put("docs", docs);
-			ctx.put("format", w.getAlertDeliveryChannel());
+    }
 
-			Collection<RenderingResult> render = rs.process(ctx);
-			if (render.size() > 0) {
-				result = (String) render.iterator().next().getOutcome();
-			}
-		} catch (Exception e) {
-			log.error("Unable to render task alerts", e);
-		}
+    private boolean isEligible(TaskDescriptor td, AlertSettingsWrapper w)
+            throws ClientException {
 
-		return result;
+        Date due = td.getDueDate();
+        Date now = new Date();
 
-	}
+        // If no due date is specified
+        if (due == null)
+            return w.getIncludeTasksWithoutDueDate();
+        else {
+            // If late task, include in the mail no matter the user preferences
+            if (due.before(now))
+                return true;
 
-	private boolean isEligible(TaskDescriptor td, AlertSettingsWrapper w) throws ClientException {
+            long days = (due.getTime() - now.getTime()) / (1000 * 60 * 60 * 24);
+            if (w.getIncludeFutureTasks()
+                    && days <= w.getIncludeFutureTasksDelay())
+                return true;
+        }
 
-		Date due = td.getDueDate();
-		Date now = new Date();
+        return false;
 
-		// If no due date is specified
-		if (due == null)
-			return w.getIncludeTasksWithoutDueDate();
-		else {
-			// If late task, include in the mail no matter the user preferences
-			if (due.before(now))
-				return true;
+    }
 
-			long days = (due.getTime() - now.getTime()) / (1000 * 60 * 60 * 24);
-			if (w.getIncludeFutureTasks() && days <= w.getIncludeFutureTasksDelay())
-				return true;
-		}
+    public DocumentViewCodecManager getLocator() {
 
-		return false;
+        if (docLocator == null) {
+            try {
+                docLocator = Framework.getService(DocumentViewCodecManager.class);
+            } catch (Exception e) {
 
-	}
+            }
+        }
 
-	public DocumentViewCodecManager getLocator() {
+        return docLocator;
+    }
 
-		if (docLocator == null) {
-			try {
-				docLocator = Framework.getService(DocumentViewCodecManager.class);
-			} catch (Exception e) {
+    public String getDocLocation(DocumentModel doc) {
 
-			}
-		}
+        DocumentLocation docLoc = new DocumentLocationImpl(doc);
+        DocumentView docView = new DocumentViewImpl(docLoc);
+        docView.setViewId("view_documents");
 
-		return docLocator;
-	}
+        return getLocator().getUrlFromDocumentView(
+                docView,
+                true,
+                NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
 
-	public String getDocLocation(DocumentModel doc) {
+    }
 
-		DocumentLocation docLoc = new DocumentLocationImpl(doc);
-		DocumentView docView = new DocumentViewImpl(docLoc);
-		docView.setViewId("view_documents");
+    public List<String> getTemplateList() {
 
-		return getLocator().getUrlFromDocumentView(docView, true,
-				NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
+        List<String> result = new ArrayList<String>();
+        result.add("taskAlert");
+        return result;
 
-	}
-
-	public List<String> getTemplateList() {
-
-		List<String> result = new ArrayList<String>();
-		result.add("taskAlert");
-		return result;
-
-	}
+    }
 
 }
diff -r cca23b73e725 -r b5ae2801e4a0 nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/WorkflowHelper.java
--- a/nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/WorkflowHelper.java	Fri Mar 26 07:28:34 2010 +0100
+++ b/nuxeo-platform-alert-task-core/src/main/java/org/nuxeo/ecm/alert/task/core/WorkflowHelper.java	Fri Mar 26 08:05:19 2010 +0100
@@ -21,7 +21,6 @@
 import org.nuxeo.ecm.platform.usermanager.UserManager;
 import org.nuxeo.runtime.api.Framework;
 
-
 public class WorkflowHelper implements Serializable {
 
     private static final long serialVersionUID = -3188848304951906233L;
@@ -34,172 +33,176 @@
 
     private JbpmService getJbpmService() throws Exception {
 
-	if (jbpmService == null) {
+        if (jbpmService == null) {
 
-	    jbpmService = Framework.getService(JbpmService.class);
+            jbpmService = Framework.getService(JbpmService.class);
 
-	}
+        }
 
-	return jbpmService;
+        return jbpmService;
 
     }
 
     private UserManager getUserManager() throws Exception {
 
-	if (userManager == null) {
+        if (userManager == null) {
 
-	    userManager = Framework.getService(UserManager.class);
-	}
+            userManager = Framework.getService(UserManager.class);
+        }
 
-	return userManager;
+        return userManager;
 
     }
 
-    public List<TaskDescriptor> getAllOpenTaskInstances() throws Exception {
+    public List<TaskDescriptor> getAllOpenTaskInstances() {
 
-	ArrayList<Criterion> c = new ArrayList<Criterion>();
+        ArrayList<Criterion> c = new ArrayList<Criterion>();
 
-	Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
-	c.add(isOpen);
+        Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
+        c.add(isOpen);
 
-	return applyCriteria(c);
+        return applyCriteria(c);
 
     }
 
-    public List<TaskDescriptor> getAllOpenTaskInstancesWithDueDate() throws Exception {
+    public List<TaskDescriptor> getAllOpenTaskInstancesWithDueDate() {
 
-	ArrayList<Criterion> c = new ArrayList<Criterion>();
+        ArrayList<Criterion> c = new ArrayList<Criterion>();
 
-	Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
-	c.add(isOpen);
-	Criterion hasDueDate = Expression.isNotNull("dueDate");
-	c.add(hasDueDate);
+        Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
+        c.add(isOpen);
+        Criterion hasDueDate = Expression.isNotNull("dueDate");
+        c.add(hasDueDate);
 
-	return applyCriteria(c);
+        return applyCriteria(c);
 
     }
 
-    public List<TaskDescriptor> getAllOpenTaskInstancesWithDueDateBefore(Date d) throws Exception {
+    public List<TaskDescriptor> getAllOpenTaskInstancesWithDueDateBefore(Date d) {
 
-	ArrayList<Criterion> c = new ArrayList<Criterion>();
+        ArrayList<Criterion> c = new ArrayList<Criterion>();
 
-	Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
-	c.add(isOpen);
-	Criterion hasDueDate = Expression.isNotNull("dueDate");
-	c.add(hasDueDate);
-	Criterion hasDueDateBefore = Expression.le("dueDate", d);
-	c.add(hasDueDateBefore);
+        Criterion isOpen = Expression.eq("isOpen", Boolean.TRUE);
+        c.add(isOpen);
+        Criterion hasDueDate = Expression.isNotNull("dueDate");
+        c.add(hasDueDate);
+        Criterion hasDueDateBefore = Expression.le("dueDate", d);
+        c.add(hasDueDateBefore);
 
-	return applyCriteria(c);
+        return applyCriteria(c);
 
     }
 
     @SuppressWarnings("unchecked")
-    private List<TaskDescriptor> applyCriteria(List<Criterion> critList) throws Exception {
+    private List<TaskDescriptor> applyCriteria(List<Criterion> critList) {
 
-	ArrayList<TaskDescriptor> result = new ArrayList<TaskDescriptor>();
+        ArrayList<TaskDescriptor> result = new ArrayList<TaskDescriptor>();
 
-	try {
+        try {
+            
+            JbpmService service = getJbpmService();
+            JbpmContext ctxt = service.getConfiguration().createJbpmContext();
+            Session s = ctxt.getSession();
 
-	    JbpmService service = getJbpmService();
-	    JbpmContext ctxt = service.getConfiguration().createJbpmContext();
-	    Session s = ctxt.getSession();
+            Criteria criteria = s.createCriteria(org.jbpm.taskmgmt.exe.TaskInstance.class);
 
-	    Criteria criteria = s.createCriteria(org.jbpm.taskmgmt.exe.TaskInstance.class);
+            for (Criterion c : critList)
+                criteria.add(c);
 
-	    for (Criterion c : critList)
-		criteria.add(c);
+            List<org.jbpm.taskmgmt.exe.TaskInstance> tasks = (List<org.jbpm.taskmgmt.exe.TaskInstance>) criteria.list();
 
-	    List<org.jbpm.taskmgmt.exe.TaskInstance> tasks = (List<org.jbpm.taskmgmt.exe.TaskInstance>) criteria.list();
+            if (tasks != null) {
+                for (TaskInstance t : tasks)
+                    result.addAll(descriptorFrominstance(t));
+            }
 
-	    if (tasks != null) {
-		for (TaskInstance t : tasks)
-		    result.addAll(descriptorFrominstance(t));
-	    }
+            ctxt.close();
 
-	    ctxt.close();
+            return result;
+        }
+        catch(Exception e) {
+            log.error("Unable to retrieve jbpmService", e);
+        }
 
-	    return result;
-
-	} catch (Exception e) {
-	    e.printStackTrace();
-	}
-
-	return new ArrayList<TaskDescriptor>();
+         return new ArrayList<TaskDescriptor>();
 
     }
 
     @SuppressWarnings("unchecked")
-    private List<TaskDescriptor> descriptorFrominstance(TaskInstance t) throws Exception {
+    private List<TaskDescriptor> descriptorFrominstance(TaskInstance t) {
 
-	List<TaskDescriptor> result = new ArrayList<TaskDescriptor>();
-	Map<String, String> variables = t.getVariables();
+        List<TaskDescriptor> result = new ArrayList<TaskDescriptor>();
+        Map<String, String> variables = t.getVariables();
 
-	TaskDescriptor taskTemplate = new TaskDescriptor();
-	taskTemplate.setDueDate(t.getDueDate());
-	taskTemplate.setName(t.getName());
-	taskTemplate.setDocumentId(variables.get("documentId"));
-	taskTemplate.setRepositoryName(variables.get("documentRepositoryName"));
+        TaskDescriptor taskTemplate = new TaskDescriptor();
+        taskTemplate.setDueDate(t.getDueDate());
+        taskTemplate.setName(t.getName());
+        taskTemplate.setDocumentId(variables.get("documentId"));
+        taskTemplate.setRepositoryName(variables.get("documentRepositoryName"));
 
-	Set si = t.getPooledActors();
-	if (si != null) {
-	    for (Object o : si) {
-		addActorToTaskList(result, taskTemplate, o);
-	    }
+        Set si = t.getPooledActors();
+        if (si != null) {
+            for (Object o : si) {
+                addActorToTaskList(result, taskTemplate, o);
+            }
 
-	}
+        }
 
-	return result;
+        return result;
     }
 
-    private void addActorToTaskList(List<TaskDescriptor> result, TaskDescriptor taskTemplate, Object o) throws Exception {
-	
-	List<String> actors = new ArrayList<String>();
-	
-	String actor = ((PooledActor) o).getActorId();
-	
-	addActorToList(actors, actor);
-	
-	result.addAll(taskTemplate.cloneForUsers(actors));
-	
-	
+    private void addActorToTaskList(List<TaskDescriptor> result,
+            TaskDescriptor taskTemplate, Object o) {
+
+        List<String> actors = new ArrayList<String>();
+
+        String actor = ((PooledActor) o).getActorId();
+
+        addActorToList(actors, actor);
+
+        result.addAll(taskTemplate.cloneForUsers(actors));
+
     }
 
-    private void addActorToList(List<String> actors, String actor) throws Exception {
+    private void addActorToList(List<String> actors, String actor) {
 
-	if (actor.contains("user:")) {
-	    addUserToActors(actors, actor.substring(5));
-	} else if (actor.contains("group:")) {
-	    String groupName = actor.substring(6);
-	    addGroupToActors(actors, groupName);
-	}
+        if (actor.contains("user:")) {
+            addUserToActors(actors, actor.substring(5));
+        } else if (actor.contains("group:")) {
+            String groupName = actor.substring(6);
+            addGroupToActors(actors, groupName);
+        }
     }
 
-    private void addGroupToActors(List<String> actors, String groupName) throws Exception {
+    private void addGroupToActors(List<String> actors, String groupName) {
 
-	UserManager um = getUserManager();
-	NuxeoGroup ng = um.getGroup(groupName);
+        try {
+            UserManager um = getUserManager();
+            NuxeoGroup ng = um.getGroup(groupName);
 
-	if (ng != null) {
+            if (ng != null) {
 
-	    List<String> users = ng.getMemberUsers();
-	    if (users != null) {
-		for (String user : users)
-		    addUserToActors(actors, user);
-	    }
-	    List<String> groups = ng.getMemberGroups();
-	    if (groups != null) {
-		for (String group : groups)
-		    addGroupToActors(actors, group);
-	    }
+                List<String> users = ng.getMemberUsers();
+                if (users != null) {
+                    for (String user : users)
+                        addUserToActors(actors, user);
+                }
+                List<String> groups = ng.getMemberGroups();
+                if (groups != null) {
+                    for (String group : groups)
+                        addGroupToActors(actors, group);
+                }
+            }
+        } catch (Exception e) {
+            log.error("Unable to retrieve group information", e);
+        }
 
-	}
     }
 
     private void addUserToActors(List<String> actors, String actor) {
 
-	if (!actors.contains(actor))
-	    actors.add(actor);
+        if (!actors.contains(actor))
+            actors.add(actor);
 
     }
 }
# HG changeset patch
# User Christophe Capon <christophe.capon@vilogia.fr>
# Date 1269587271 -3600
# Branch 5.3.0
# Node ID e279cd5bf8c7997b1d71eb212aeb7f50b88527bf
# Parent  b5ae2801e4a055eca1fd4bab420b0cf7e1c32956
Fixed minor warnings and test classes

diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java
--- a/nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java	Fri Mar 26 08:05:19 2010 +0100
+++ b/nuxeo-platform-alert-core/src/main/java/org/nuxeo/ecm/alert/core/AlertManagementServiceImpl.java	Fri Mar 26 08:07:51 2010 +0100
@@ -162,7 +162,7 @@
     }
 
     private Map<String, UserAlerts> getAvailableAlerts(CoreSession coreSession,
-            AlertContext ctx) {
+            AlertContext ctx) throws ClientException {
         Map<String, UserAlerts> allAlerts = new HashMap<String, UserAlerts>();
 
         Iterator<Entry<String, AlertProvider>> iter = alertProviders.entrySet().iterator();
diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/EmailHelperMock.java
--- a/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/EmailHelperMock.java	Fri Mar 26 08:05:19 2010 +0100
+++ b/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/EmailHelperMock.java	Fri Mar 26 08:07:51 2010 +0100
@@ -1,8 +1,5 @@
 package org.nuxeo.ecm.alert.core;
 
-import java.io.File;
-import java.io.FileWriter;
-
 import org.nuxeo.ecm.alert.EmailHelper;
 import org.nuxeo.ecm.core.api.ClientException;
 
diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/FakeUserManagerImpl.java
--- a/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/FakeUserManagerImpl.java	Fri Mar 26 08:05:19 2010 +0100
+++ b/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/FakeUserManagerImpl.java	Fri Mar 26 08:07:51 2010 +0100
@@ -20,8 +20,6 @@
 package org.nuxeo.ecm.alert.core;
 
 import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -31,27 +29,11 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.jboss.seam.web.Session;
-import org.nuxeo.common.collections.ScopeType;
-import org.nuxeo.common.collections.ScopedMap;
-import org.nuxeo.common.utils.Path;
 import org.nuxeo.ecm.core.api.ClientException;
-import org.nuxeo.ecm.core.api.CoreSession;
-import org.nuxeo.ecm.core.api.DataModel;
-import org.nuxeo.ecm.core.api.DataModelMap;
-import org.nuxeo.ecm.core.api.DocumentException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.nuxeo.ecm.core.api.DocumentRef;
 import org.nuxeo.ecm.core.api.NuxeoGroup;
 import org.nuxeo.ecm.core.api.NuxeoPrincipal;
-import org.nuxeo.ecm.core.api.impl.DocumentModelImpl;
-import org.nuxeo.ecm.core.api.model.DocumentPart;
-import org.nuxeo.ecm.core.api.model.Property;
-import org.nuxeo.ecm.core.api.model.PropertyException;
-import org.nuxeo.ecm.core.api.security.ACP;
-import org.nuxeo.ecm.core.api.security.SecurityConstants;
-import org.nuxeo.ecm.core.schema.DocumentType;
 import org.nuxeo.ecm.platform.usermanager.NuxeoPrincipalImpl;
 import org.nuxeo.ecm.platform.usermanager.UserManager;
 import org.nuxeo.ecm.platform.usermanager.UserManagerDescriptor;
diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/TestAlertCore.java
--- a/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/TestAlertCore.java	Fri Mar 26 08:05:19 2010 +0100
+++ b/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/TestAlertCore.java	Fri Mar 26 08:07:51 2010 +0100
@@ -20,17 +20,14 @@
  */
 
 import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.util.regex.Pattern;
 
 import org.nuxeo.ecm.alert.AlertContext;
 import org.nuxeo.ecm.alert.AlertEvent;
 import org.nuxeo.ecm.alert.AlertManagementService;
+import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.event.EventService;
 import org.nuxeo.runtime.api.Framework;
 
@@ -129,7 +126,7 @@
 	public void testStartup() {
 	}
 
-	public void test2Providers() {
+	public void test2Providers() throws ClientException {
 		
 		AlertContext ctx = new AlertContext();
 		ctx.setEventId(AlertEvent.MANUAL_ALERT_EVENT);
@@ -137,25 +134,8 @@
 		assertEquals(mock.getLastTo(), "testuser@domain.com");
 		assertEquals(mock.getLastSubject(), AlertManagementImplConstants.MAIL_SUBJECT);
 
-//		try {
-//
-//			InputStream s = this.getClass().getClassLoader().getResourceAsStream("expected/test2Providers.html");
-//			if (s==null) throw new Exception("Unable to open");
-//			String expected = removeHrefs(getFileContents(s));
-//			String actual = removeHrefs(mock.getLastBody());
-//			assertEquals(expected, actual);
-//		} catch (Exception e) {
-//			fail("Unable to load comparison file");
-//		}
-
 	}
-
-	private String removeHrefs(String html) {
-
-		return html.replaceAll("<a href=[^>]*>", "");
-
-	}
-
+	
 	public String getFileContents(InputStream filename) throws IOException {
 		
 		char[] buffer = new char[512];
diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/WrappedUserManagerDescriptor.java
--- a/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/WrappedUserManagerDescriptor.java	Fri Mar 26 08:05:19 2010 +0100
+++ b/nuxeo-platform-alert-core/src/test/java/org/nuxeo/ecm/alert/core/WrappedUserManagerDescriptor.java	Fri Mar 26 08:07:51 2010 +0100
@@ -1,19 +1,20 @@
 package org.nuxeo.ecm.alert.core;
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.regex.Pattern;
 
-import org.nuxeo.common.xmap.annotation.XNode;
-import org.nuxeo.common.xmap.annotation.XNodeMap;
 import org.nuxeo.ecm.platform.usermanager.UserManagerDescriptor;
 import org.nuxeo.ecm.platform.usermanager.VirtualUserDescriptor;
-import org.nuxeo.ecm.platform.usermanager.UserManager.MatchType;
 
 public class WrappedUserManagerDescriptor extends UserManagerDescriptor {
 
-	public WrappedUserManagerDescriptor(UserManagerDescriptor init) {
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 1738447024467990837L;
+
+
+    public WrappedUserManagerDescriptor(UserManagerDescriptor init) {
 		this.merge(init);
 	}
 
diff -r b5ae2801e4a0 -r e279cd5bf8c7 nuxeo-platform-alert-core/src/test/resources/expected/test2Providers.html
--- a/nuxeo-platform-alert-core/src/test/resources/expected/test2Providers.html	Fri Mar 26 08:05:19 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<style type="text/css"></style></head>
-<body style="margin: 0; padding: 0;" class="nxStyle1136222341PageFrame">
-
-<div class="nxStyle1374513806 nxStyle837759872 nxStyle1433358016 nxStyle174692559FaceletRegion">
-
-<div>
-<h1>Votre rapport d'alertes</h1>
-<p class="currentDocumentDescription">Le contenu de ce rapport peut être modifié <a href="http://localhost:8080/nuxeo/nxdoc/demo/d427e37f-ac43-49b0-bef7-986327623a44/view_documents">ici</a></p>
-</div>
-This is the test string 1
-This is the test string 2
-</div>
-</body>
-</html>
